<?php

namespace app\index\controller;

class Index extends Base
{
    public function __construct()
    {
        parent::__construct();

    }

    public function index()
    {

    }

    public function contractFor($i)
    {
        $this->contract->at($this->ldAddress)->call('getPlayerVaults', 4, function ($err, $result) use ($i) {
            if ($result) {
                $res = $this->hextostr($result);
                $this->api_export([
                    "body" => $res,
                    "times" => $i,
                    "err" => $err
                ]);
            } else {
                $i++;
                if ($i < 15) {
                    $this->contractFor($i);
                } else {
                    $this->api_error("20000", "error to query,times:" . $i);
                }
            }
        });
    }
}
